Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the capability to assimilate the MADIS snow depth data from GTS #1836

Merged
merged 13 commits into from
Sep 13, 2023

Conversation

jiaruidong2017
Copy link
Contributor

@jiaruidong2017 jiaruidong2017 commented Sep 5, 2023

This PR updates the land_analysis.py to add the capability to assimilate the madis snow depth data from GTS.

This PR depends on GDASApp #602

How has this been tested?

Clone and build on Hera
Cycled test on Hera Run C384/C192 L127 for 2023050100.
Observations on hera at /scratch1/NCEPDEV/global/Jiarui.Dong/JEDI/GlobalWorkflow/para_gfs/glopara_dump/gdas.20230501/

Checklist

  • Any dependent changes have been merged and published
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass with my changes
  • I have made corresponding changes to the documentation if necessary

Copy link
Contributor

@WalterKolczynski-NOAA WalterKolczynski-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these different steps should probably be broken into individual methods that prepare_GTS calls, as it is getting a bit long now and doing multiple things. Will see what @aerorahul thinks.

Comment on lines 130 to 131
if os.path.isfile(f"{os.path.join(localconf.DATA, output_file)}"):
rm_p(output_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if os.path.isfile(f"{os.path.join(localconf.DATA, output_file)}"):
rm_p(output_file)
rm_p(output_file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above lines were removed.

Copy link
Contributor

@aerorahul aerorahul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good. We can work to make it better and data driven.

Comment on lines 13 to 14
export BUFRADPSFCYAML="${HOMEgfs}/sorc/gdas.cd/test/testinput/bufr_adpsfc_snow.yaml"
export BUFRSNOCVRYAML="${HOMEgfs}/sorc/gdas.cd/test/testinput/bufr_snocvr.yaml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these yamls be in parm/land/ and not test/?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the GTS bufr2ioda yamls in GDASApp are saved at the test/testinput/ directory.

Comment on lines 121 to 140
logger.info(f"Executing {exe}")
try:
exe()
except OSError:
raise OSError(f"Failed to execute {exe}")
except Exception:
raise WorkflowException(f"An error occured during execution of {exe}")

output_file = f"{localconf.OPREFIX}snocvr_snow.nc4"
if os.path.isfile(f"{os.path.join(localconf.DATA, output_file)}"):
rm_p(output_file)

# execute BUFR2IODAX to convert snocvr bufr data into IODA format
yaml_file = f"bufr_snocvr.yaml"
if not os.path.isfile(f"{os.path.join(localconf.DATA, yaml_file)}"):
logger.exception(f"{yaml_file} not found")
raise FileNotFoundError(f"{os.path.join(localconf.DATA, yaml_file)}")
exe = Executable(self.task_config.BUFR2IODAX)
exe.add_default_arg(os.path.join(localconf.DATA, f"{yaml_file}"))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suggestion to remove some repetition here. Please see the patch on this file if you could kindly test.
diff.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this, and it worked perfect. The updates were committed to the repo. Thanks @aerorahul for your suggestions.

Comment on lines 90 to 100
# generate bufr2ioda YAML files
adpsfc_yaml = os.path.join(self.runtime_config.DATA, "bufr_adpsfc_snow.yaml")
logger.info(f"Generate BUFR2IODA YAML file: {adpsfc_yaml}")
temp_yaml = parse_j2yaml(self.task_config.BUFRADPSFCYAML, self.task_config)
save_as_yaml(temp_yaml, adpsfc_yaml)
logger.info(f"Wrote bufr2ioda YAML to: {adpsfc_yaml}")
snocvr_yaml = os.path.join(self.runtime_config.DATA, "bufr_snocvr.yaml")
logger.info(f"Generate BUFR2IODA YAML file: {snocvr_yaml}")
temp_yaml = parse_j2yaml(self.task_config.BUFRSNOCVRYAML, self.task_config)
save_as_yaml(temp_yaml, snocvr_yaml)
logger.info(f"Wrote bufr2ioda YAML to: {snocvr_yaml}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may be able to make this a bit less hard-coded and yaml driven from the top.
Say for e.g. somewhere in GDASApp/parm/land has bufr2ioda.yaml that contains:

bufr2ioda:
     adpsfc: {{ HOMEgfs }}/sorc/gdas.cd/test/testinput/bufr_adpsfc_snow.yaml
     snocvr: {{ HOMEgfs }}/sorc/gdas.cd/test/testinput/bufr_snocvr.yaml

We could then loop over this list to parse the yamls, and call the bufr2ioda.x and verify the output is produced.

The code then does not know what it is processing and bufr files can be added/removed to the yaml.

Would this be acceptable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may be able to use land/prep/prep_gts.yaml as it already seems to have the appropriate information and it is likely better to keep them together.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aerorahul Follow your suggestions, I have made the changes for your review. Thanks.

Comment on lines 90 to 96
# generate bufr2ioda YAML files
for name in ["adpsfc", "snocvr"]:
gts_yaml = os.path.join(self.runtime_config.DATA, f"bufr_{name}_snow.yaml")
logger.info(f"Generate BUFR2IODA YAML file: {gts_yaml}")
temp_yaml = parse_j2yaml(prep_gts_config.bufr2ioda[name], localconf)
save_as_yaml(temp_yaml, gts_yaml)
logger.info(f"Wrote bufr2ioda YAML to: {gts_yaml}")
Copy link
Contributor

@aerorahul aerorahul Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this section @jiaruidong2017
Here is what I was suggesting.
In the attached patch, you will notice that I have removed any knowledge of what is being converted from bufr to ioda in the python script. The control comes directly from the yaml.

Would you be willing to give this a try?
diff.txt

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aerorahul. I will try it and let you know then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aerorahul I just tested and it worked perfectly. The changes have been committed to the repo.

# execute BUFR2IODAX to convert snocvr bufr data into IODA format
_gtsbufr2iodax(exe, os.path.join(localconf.DATA, "bufr_snocvr_snow.yaml"))
# execute BUFR2IODAX to convert {name} bufr data into IODA format
_gtsbufr2iodax(exe, os.path.join(localconf.DATA, f"bufr_{name}_snow.yaml"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_gtsbufr2iodax(exe, os.path.join(localconf.DATA, f"bufr_{name}_snow.yaml"))
_gtsbufr2iodax(exe, gts_yaml)

In my second (revised diff.txt), I removed the need to construct this again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done the changes.

Copy link
Contributor

@aerorahul aerorahul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Thank you for accepting suggestions.
If I could make one more suggestion that aids in knowing the inputs of this method completely, is to consolidate everything that is needed into localconf and then only use localconf everywhere.
At present, you will notice, variables are being accessed from task_config, runtime_config as well as localconf.

@jiaruidong2017
Copy link
Contributor Author

Looks good. Thank you for accepting suggestions. If I could make one more suggestion that aids in knowing the inputs of this method completely, is to consolidate everything that is needed into localconf and then only use localconf everywhere. At present, you will notice, variables are being accessed from task_config, runtime_config as well as localconf.

Thanks @aerorahul for the detailed instructions, and I have benefited a lot when I was working with you on this PR.

@jiaruidong2017
Copy link
Contributor Author

@aerorahul This PR depends on the NOAA-EMC/GDASApp#602. Would you please take time to review it? Thanks again.

@aerorahul
Copy link
Contributor

@jiaruidong2017
Let us know when you want us to merge this PR. It is good to go from this side.

@jiaruidong2017
Copy link
Contributor Author

@aerorahul we need to wait for @CoryMartin-NOAA to merge the recent updates in GDASApp into the feature/stable-nightly, and update the commit hash in the global-workflow. I will let you know when it is ready. Thanks.

@CoryMartin-NOAA
Copy link
Contributor

@jiaruidong2017 already done... d347d22

@jiaruidong2017
Copy link
Contributor Author

Thanks @CoryMartin-NOAA I have updated the commit hash for the GDASApp.
@aerorahul @WalterKolczynski-NOAA It is ready to merge this PR. Thanks.

@aerorahul aerorahul dismissed WalterKolczynski-NOAA’s stale review September 13, 2023 13:59

requested changed were made.

@aerorahul aerorahul merged commit ffa9445 into NOAA-EMC:develop Sep 13, 2023
3 checks passed
@jiaruidong2017 jiaruidong2017 deleted the feature/madis_da branch September 13, 2023 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants